package com.lin.springboottest.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lin.springboottest.model.po.SysUser;
import com.lin.springboottest.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/sysUser")
public class SysUserController {

    private final ISysUserService sysUserService;

    @GetMapping("/hello/{id}")
    public ResponseEntity test(@PathVariable Integer id){
        SysUser sysUser = sysUserService.getById(id);
        return ResponseEntity.ok(sysUser);
    }


    @GetMapping("/testDel/{id}")
    public ResponseEntity testDel(@PathVariable Integer id){
        return ResponseEntity.ok(sysUserService.removeById(id));
    }

    @GetMapping("/getListByPage")
    public ResponseEntity getListByPage(){
        return ResponseEntity.ok(sysUserService.getListByPage());
    }

    @GetMapping("/addSysUser")
    public ResponseEntity addSysUser(){
        SysUser sysUser = new SysUser();
        sysUser.setUsername("ceshi");
        sysUser.setPassword("123");
        return ResponseEntity.ok(sysUserService.save(sysUser));
    }

}
